package cn.hsp;

import com.mysql.jdbc.Driver;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;

public class Jdbc2 {
    public static void main(String[] args) {
        try {
            Class<?> clazz = Class.forName("com.mysql.cj.jdbc.Driver");
            Driver driver = (Driver) clazz.newInstance();
            String url = "jdbc:mysql://localhost:3307/empdb";
            Properties info = new Properties();
            info.setProperty("user","root");
            info.setProperty("password","0616");
            Connection conn = driver.connect(url,info);
            Statement s = conn.createStatement();
            s.executeUpdate("insert into hero values (null,'刘备',255)");
            s.close();
            conn.close();
        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | SQLException e) {
            e.printStackTrace();
        }
    }
}
